<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>table-cell布局</title>
		<style>
			.box {
				height: 200px;
				width: 200px;
				display: table-cell;
				text-align: center;
				border: 1px solid #ccc;
				vertical-align: middle;
			}
			p{
				width: 200px;
				background-color: #f20;;
				line-height: 30px;
				display: inline-block;
				color: #fff;
				margin: 0;
			}
			.text2{
				margin-top: 5px;
				height: 40px;
				line-height: 40px;
				font-size: 20px;
			}
		</style>
	</head>

	<body>
		图片定高|不定高水平垂直居中
		<div class="box">
			<img src="https://ss1.baidu.com/70cFfyinKgQFm2e88IuM_a/forum/pic/item/242dd42a2834349b406751a3ceea15ce36d3beb6.jpg">
		</div>
		多行定高|不定高|定宽|不定宽水平垂直居中
		<div class="box">
			<p>水平居中水平</p>
			<p class="text2">垂直居中垂直居中</p>
		</div>
	</body>

</html>